/**
  ******************************************************************************
  * @file 
  * @brief 
  * @author samuel-zsy
  * @version V1.0.0
  * @date 2018/07/17
  ******************************************************************************
  */
#ifndef _lwip_app_H
#define _lwip_app_H 

#include "stdint.h"
#include <stdbool.h>
/* Public defines -----------------------------------------------------------*/
typedef uint8_t	SOCKET;

//#define __DEF_IINCHIP_DBG__
#define _WIZCHIP_                      5500   // 5100, 5200, 5500

#define SOCKET_BUFF_NUM         0x200//0x2000  //4096B
#define SOCKET_EEFECTIVE_NUM    2       //

#define SOCKET_NUMBER_1     (uint8_t)(0)
#define SOCKET_NUMBER_2     (uint8_t)(1)

#if _WIZCHIP_ > 5100
   #define _WIZCHIP_SOCK_NUM_   8   ///< The count of independant socket of @b WIZCHIP
#else
   #define _WIZCHIP_SOCK_NUM_   4   ///< The count of independant socket of @b WIZCHIP
#endif      


/* Public Struct  -----------------------------------------------------------*/
typedef struct _CONFIG_MSG
{
  uint8_t mac[6];
  uint8_t lip[4];
  uint8_t sub[4];
  uint8_t gw[4];
  uint8_t dns[4];	
}CONFIG_MSG;

struct Socket_Struct
{
	SOCKET socket_num;
	struct{
		uint8_t ip[4];
		uint16_t port;
	}local,remote;

	uint16_t buff_len;
	uint8_t *buff;
    uint8_t last_connect_flag;
	uint8_t connect_flag;
	void (*loopback)(SOCKET,uint16_t);
};
/* Public enum    -----------------------------------------------------------*/


/* Public Variable  ---------------------------------------------------------*/
//Pointer

//Array

//Const
extern	CONFIG_MSG  ConfigMsg;

/* Pubilc function prototypes -----------------------------------------------*/
void LWIP_App_Init         ( void );

void loopback_tcp_server   ( SOCKET s, uint16_t port );

void eth_loopback_task(void *p_arg);

uint8_t tcp_senddata       ( uint8_t *data, uint16_t len );

uint8_t udp_senddata       ( uint8_t *data, uint16_t len );

void Set_Default(void);
#endif /* _lwip_app_H */

/******************* (C) COPYRIGHT 2018 CIQTEK Samuel *****END OF FILE****/
